﻿using System.Windows;
using System.Windows.Controls;

namespace Asistente.Converters
{
    /// <summary>
    /// This TemplateSelector Select between Panels template and MasterDetails template.
    /// It's used when a Screen node is expanded.
    /// </summary>
    public class PanelMasterDetailsTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var element = container as FrameworkElement;

            if (element != null && item is Model.Representation.Panel)
            {
                return element.FindResource("PanelTemplate") as DataTemplate;
            }
            else{
                if (element != null) 
                    return element.FindResource("MasterDetailsTemplate") as DataTemplate;
            }
            return null;
        }
    }
}


